execute pathogen#infect()
call pathogen#helptags()
colorscheme darkZ            
set guifont=YaHei_Consolas_Hybrid:h11:cGB2312" 字体 && 字号
set tabstop=4                " 设置tab键的宽度
set shiftwidth=4             " 换行时行间交错使用4个空格
set autoindent               " 自动对齐
set backspace=2              " 设置退格键可用
set cindent shiftwidth=4     " 自动缩进4空格
set smartindent              " 智能自动缩进
set ai!                      " 设置自动缩进
set nu                      " 显示行号
set mouse=nicr                   "不能用鼠标选取文本,避免了鼠标点击时的干扰 
set showmatch               " 显示括号配对情况
set ruler                    " 右下角示光标位置的状态行
set incsearch                " 查找book时，当输入/b时会自动找到
set hlsearch                 " 开启高亮显示结果
set incsearch                " 开启实时搜索功能
set nowrapscan               " 搜索到文件两端时不重新搜索
set nocompatible             " 关闭兼容模式
set vb t_vb=                 " 关闭提示音
set hidden                   " 允许在有未保存的修改时切换缓冲区
set list                     " 显示tab符，使用一高亮竖线代替
set listchars=tab:\|\ ,
set clipboard=unnamed        " 与win共用剪贴板
syntax enable                " 打开语法高亮
syntax on                    " 开启文件类型侦测
filetype indent on           " 针对不同的文件类型采用不同的缩进格式
filetype plugin on           " 针对不同的文件类型加载对应的插件
filetype plugin indent on    " 启用自动补全
if has("gui_running")
    au GUIEnter * simalt ~x  " 窗口启动时自动最大化
    "winpos 20 20            " 指定窗口出现的位置，坐标原点在屏幕左上角
    "set lines=20 columns=90 " 指定窗口大小，lines为高度，columns为宽度
    set guioptions-=m       " 隐藏菜单栏
    set guioptions-=T        " 隐藏工具栏
    set guioptions-=L       " 隐藏左侧滚动条
    set guioptions-=r       " 隐藏右侧滚动条
    "set guioptions-=b       " 隐藏底部滚动条
    set showtabline=0       " 隐藏Tab栏
endif

" backup file ~  swap file .swp
set writebackup              " 设置无备份文件
set nobackup
set noswapfile               "  设置无交换文件
" set dir=d:\tmp                " swap file dir
" set backupdir=d:\tmp          " backup file dir
" set nowrap                  " 设置不自动换行
set autochdir                " 设定文件浏览器目录为当前目录
set foldmethod=indent        " 选择代码折叠类型
set foldlevel=99            " 禁止自动折叠
set laststatus=2             " 开启状态栏信息
set cmdheight=1              " 命令行的高度，默认为1，这里设为2

" 设置编码
set fenc=utf-8
set encoding=utf-8
set fileencodings=utf-8,gbk,cp936,latin-1
" 解决菜单乱码
source $VIMRUNTIME/delmenu.vim
"source $VIMRUNTIME/menu.vim "删除鼠标右键菜单
" 解决consle输出乱码
language messages zh_CN.utf-8

" Omni Completion *************************************************************
"set ofu=syntaxcomplete#Complete
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
"当文件是html时，全能补全函数为htmlcomplete.vim中的CompleteTags
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" May require ruby compiled in
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete 
:inoremap <c-space> <c-x><c-o>


" Windows
set equalalways " Multiple windows, when created, are equal in size
set splitright "splitbelow

"Vertical split then hop to new buffer
:noremap ,v :vsp^M^W^W<cr> " 等同于 <c-w>v
:noremap ,h :split^M^W^W<cr> "等同于 <c-w>s

" 自定义快捷键
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
:imap jj <ESC>
:nnoremap <UP> <nop>
:nnoremap <DOWN> <nop>
:nnoremap <LEFT> <nop>
:nnoremap <RIGHT> <nop>
:inoremap <UP> <nop>
:inoremap <DOWN> <nop>
:inoremap <LEFT> <nop>
:inoremap <RIGHT> <nop>
:inoremap <F1> <nop>
:nnoremap <F1> <nop>
" ======= 引号 && 括号自动匹配 ======= "
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
:inoremap ` ``<ESC>i
function! ClosePair(char)
	if getline('.')[col('.') - 1] == a:char
		return "\<Right>"
	else
		return a:char
	endif
endf

" NERDTree
:noremap ,n :NERDTreeToggle<CR>

" User instead of Netrw when doing an edit /foobar
let NERDTreeHijackNetrw=1

" Single click for everything
let NERDTreeMouseMode=1

let NERDTreeIgnore=['\.svn$', '\~$', '\.pyc$', '\.beam$', '\.gz$'] 

" TagList
map ,t :Tlist<CR>
let Tlist_Show_One_File = 1
let Tlist_Ctags_Cmd = '"D:\vim\tools\ctags.exe"'
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_Right_Window = 1
"
" 运行可执行文件
func! RunResult()
        exec "w"
        if &filetype == "python"
			exec "!python %<.py"
		elseif &filetype == "ruby"
			exec "!ruby %<.rb"
        endif
endfunc

" <F11> 一键保存、运行
map <F11> :call RunResult()<CR>
imap <F11> <ESC>:call RunResult()<CR>
vmap <F11> <ESC>:call RunResult()<CR>

" ======= VimWiki ======= "
let g:vimwiki_menu = ''
let g:vimwiki_hl_cb_checked = 1
" 设置编码
let g:vimwiki_w32_dir_enc = 'utf-8'
" 使用鼠标映射
let g:vimwiki_use_mouse = 1
" 不要将驼峰式词组作为 Wiki 词条
let g:vimwiki_camel_case = 0
" 声明可以在wiki里面使用的HTML标签
let g:vimwiki_valid_html_tags='font,b,i,s,u,sub,sup,kbd,br,hr,div,del,code,red,center,left,right,h4,h5,h6,pre'
let g:vimwiki_list = [{
\ 'path': 'D:/notes/wiki/',
\ 'path_html': 'D:/notes/html/',
\ 'template_path': 'D:/notes/template/',
\ 'template_default': 'tmp',
\ 'template_ext': '.html',
\ 'html_header': 'D:/notes/template/header.html',
\ 'html_footer': 'D:/notes/template/footer.html',
\ 'auto_export': 1,
\ 'nested_syntaxes': {'C': 'c', 'C++': 'cpp', 'Haskell': 'haskell', 'Ruby': 'ruby', 'SQL': 'sql', 'HTML': 'html', 'CSS': 'css', 'JavaScript': 'javascript', 'Vim': 'vim', 'Make': 'make'},}]

" 日历
"map <F8> :Calendar<cr>

autocmd BufRead *.as set filetype=actionscript
" actionscript language
let tlist_actionscript_settings = 'actionscript;c:class;f:method;p:property;v:variable'

" session
set sessionoptions-=curdir
set sessionoptions+=sesdir

" map leader
let mapleader=','

"let g:pydiction_location = 'D:/vim/vimfiles/bundle/pydiction/complete-dict'
